<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			* {
				margin: 0px;
				padding: 0px;
			}
		</style>
	</head>

	<body style="background: #fff;">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<!--	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style=""></a>-->
			<h1 class="mui-title">发表评论</h1>
		</header>
		<div id="box" class="mui-content" style="background: #fff;">
			<div class="mui-content" style="background: #fff;margin-bottom: 13em;" id="div">

			</div>
			<div>
				<div class="mui-input-row" style="margin: 10px 5px;position: fixed;bottom: 2.4em;width: 98%;">
					<textarea rows="5" placeholder="请输入评价" id="username" v-model="username"></textarea>
				</div>
				<a id='a_Div' style="background: burlywood;position: fixed;bottom: 0;height: 2.5em; line-height:2.5em;width: 100%;text-align: center;color: white;font-size: 1.4em;" v-on:click="show()">
					提交点评
				</a>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/initData.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/jquery-3.1.1.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script type="text/javascript">
			mui.init()
			var com_id;
			var text;
			mui.plusReady(function() {
				com_id = plus.webview.currentWebview().company_id;
				mui.ajax(url_supporter_comments, {
					data: {
						"id": com_id,
						"pn": -1
					},
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						plus.nativeUI.closeWaiting();
						var array = JSON.parse(data).value;
						mui.each(array, function(index, item){
							var test = new Date(parseInt(item.createDate) );  
						    var $_year = test.getFullYear();  
						    var $_month = parseInt(test.getMonth())+1;  
						    var $_day = test.getDate();  
						    var $_f_date =  $_year +"-"+$_month+"-"+$_day  
							item = "<div style='margin:0.7em;border-bottom: 1px solid darkgrey ;padding-bottom: 0.7em;'><p style='color: #000;font-size: 0.9em'>"+item.text+"</p><p style='font-size: 0.8em;color: darkgrey;padding-bottom: 0.5em;'><span style='float: right;'>"+$_f_date+"</span></p></div>";
                        	$('#div').append(item);
						});
					},
					error: function(xhr, type, errorThrown) { //异常处理；
						console.log(type);
						console.log(errorThrown);
						plus.nativeUI.closeWaiting();
					}
				});
			});
			window.onload = function() {
				var vue = new Vue({
					el: '#box',
					data: {
						json: [],
						username: ''
					},
					methods: { //方法
						show: function() {
							if(this.username == '') {
								mui.alert('请输入评价')
							} else {
								text = this.username;
								mui.ajax(url_supporter_comment, {
									data: {
										"pid": com_id,
										"text": text
									},
									type: 'post', //HTTP请求类型
									timeout: 10000, //超时时间设置为10秒；
									success: function(data) {
										plus.nativeUI.closeWaiting();
										console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
										console.log(data);
										vue.json.push({
											name: text
										});
									},
									error: function(xhr, type, errorThrown) { //异常处理；
										console.log(type);
										console.log(errorThrown);
										plus.nativeUI.closeWaiting();
									}
								});
								this.username = '';
							}
						}
					}
				});

			};
		</script>
	</body>

</html>